package com.shijie.newvideo;

import android.content.Context;
import android.view.View;

import com.shijie.newvideo.base.BaseRecyclerViewAdapter;
import com.shijie.newvideo.base.BaseRecyclerViewHolder;
import com.shijie.newvideo.databinding.ItemVodDownVideoBinding;

import java.util.List;

public class DownListAdapter extends BaseRecyclerViewAdapter<IdNameBean> {
    public DownListAdapter(Context context, List<IdNameBean> data) {
        super(context, data);
    }

    @Override
    protected BaseRecyclerViewHolder<IdNameBean> createViewHolder(View itemView) {
        return new ViewHolder(ItemVodDownVideoBinding.bind(itemView));
    }

    @Override
    protected int getItemLayoutRes(int viewType) {
        return R.layout.item_vod_down_video;
    }

    class ViewHolder extends BaseRecyclerViewHolder<IdNameBean> {
        private final ItemVodDownVideoBinding binding;

        public ViewHolder(ItemVodDownVideoBinding binding) {
            super(binding.getRoot());
            this.binding = binding;
        }

        @Override
        public void bindTo(final IdNameBean bean, final int position) {
            super.bindTo(bean, position);
            binding.videoName.setText(bean.getName());

            // 获取进度并更新UI     bean.getUrl()
            int progress = getDownloadProgress(bean);
            binding.progressBar.setProgress(progress);
            binding.progressText.setText(progress + "%");
        }
    }
    private int getDownloadProgress(IdNameBean video) {
        return 0;
    }
}
